home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / ANTENNA / YAGIU112 / RANTEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-07  |  1.0 KB  |  28 lines

  1. #include <stdio.h>
  2. #include "yagi.h"
  3.  
  4. #define MAX 1000
  5.  
  6. void         seedRNG();
  7. int main(int argc, char **argv)
  8. {
  9.     int i, k;
  10.     double realtype=0, inttype=0;
  11.  
  12.     k=MAX;
  13.  
  14.     seedRNG();
  15.  
  16.     printf("This program prints a few integers and reals, to test your implementation of the random number generator (RNG) is okay. Run the program again to check they produce a different set of numbers - if not the RNG is not seeded correctly.\n");
  17.     for(i=1;i<=10;++i)
  18.         printf("%lf %d\n", randreal(), randint());
  19.     printf("Now we print the average of %d floats and integers. If the figures are wildly different from those expected, check the RNG. The integer type must retun a number between 0 and 2^15-1. If It returns one between 0 and 2^31-1, you will need to modify the function randint()\n",k);
  20.     for(i=1;i<=MAX;++i)
  21.     {
  22.         realtype+=randreal();
  23.         inttype+=randint();
  24.     }
  25.     printf("The mean of %d floats was %.4lf. It should have been about 0.5\n", MAX, realtype/MAX);
  26.     printf("The mean of %d its was %.4lf. It should have been about 16384\n", MAX, inttype/MAX);
  27. }
  28.